package com.lagou.pojo;

import org.springframework.data.domain.Page;

import java.util.List;

public class PageInfo<T> {

    private int firstPage;

    private int lastPage;

    private int prePage;

    private int nextPage;

    private int pageNum;

    private List<T> list;

    public PageInfo(int page, int size, Page<T> content) {
        this.list = content.getContent();
        this.firstPage = 0;
        this.nextPage = page + 1;
        this.lastPage =  content.getTotalPages() - 1;
        this.pageNum = size;
        this.prePage = page == 0 ?  0 : page;
    }

    public int getFirstPage() {
        return firstPage;
    }

    public void setFirstPage(int firstPage) {
        this.firstPage = firstPage;
    }

    public int getLastPage() {
        return lastPage;
    }

    public void setLastPage(int lastPage) {
        this.lastPage = lastPage;
    }

    public int getPrePage() {
        return prePage;
    }

    public void setPrePage(int prePage) {
        this.prePage = prePage;
    }

    public int getNextPage() {
        return nextPage;
    }

    public void setNextPage(int nextPage) {
        this.nextPage = nextPage;
    }

    public int getPageNum() {
        return pageNum;
    }

    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }
}


